/*
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package timers;

import java.util.Timer;
import java.util.TimerTask;

import commandhandlers.HelpHandler;

/**
 * Used when someone is pasting news to the bot. If they don't signal the end of the pasting the bot will automatically, through
 * this class, end it after a set amount of time
 * 
 * 
 */
public class HelpTimer extends Timer {
   /**
    * A Class that represents a task to be done when the timer runs out
    * 
    * 
    */
   private static class ToDoTask extends TimerTask {
	  private final String sender;
	  private final HelpHandler handler;

	  public ToDoTask(final String sender, final HelpHandler handler) {
		 super();
		 this.sender = sender;
		 this.handler = handler;
	  }

	  @Override
	  public void run() {
		 handler.removeHelpAdd(sender);
	  }
   }

   private final String sender;

   public HelpTimer(final String sender, final HelpHandler handler) {
	  super();
	  schedule(new ToDoTask(sender, handler), 30000);
	  this.sender = sender;
   }

   public String getUser() {
	  return sender;
   }
}
